//
//  VideoModel.swift
//  OnceNectar
//
//  Created by 法正磊 on 2018/2/8.
//  Copyright © 2018年 com.inwhoop. All rights reserved.
//

import UIKit
import SwiftyJSON
import MappingAce
struct VideoModel:Mapping {
//    /// 浏览量
//    var browsingVolume = String(format: "%lu", arc4random() % 9999 + 1)
//    /// 标题
//    var titleContent = "这是一个视频"
//    /// 视频链接
//    var videoUrl = ""
//    /// 用户信息
//    var userInfoModel = UserInfoModel()
//    /// 评论信息
//    var comments:[ConsultaionCommentModel] = []
    
    var id:String?
    var title:String?
    var coverImgJointId:String?
    var status:String?
    var statusDesc:String?
    var delFlag:String?
    var circle:String?
    var publishTime:String?
    var auditUserId:String?
    var auditUserName:String?
    var auditTime:String?
    var denyReason:String?
    var coverImgPath:String?
    var labels : [InterestMarkModel]?
    var favorite: String?
    var browse: String?
    var comment:String?
    var collected:String?
    var summary:String?
    var fileJointId:String?
    var ascription:String?
    var videoFilePath:String?
    var shareUrl:String?
    var redirectType:String?

    var label:InterestMarkModel?
    var author:AuthorModel?
    var channel:ChannelModel?

}
extension VideoModel {
    init(_ json: [String: Any]) {
//        let jsonData = JSON(json).dictionaryValue
//        let url = jsonData["videoUrl"]?.string ?? ""
//        videoUrl = Bundle.main.path(forResource: url, ofType: nil)!
//        let comments = jsonData["comments"]?.array
//        for comment in comments! {
//            let comDic = comment.dictionary
//            var comData = ConsultaionCommentModel()
//            comData.userInfoModel.name = comDic!["name"]?.string ?? ""
//            comData.commentContent = comDic!["content"]?.string ?? ""
//            self.comments.append(comData)
//        }
    }
    
    mutating func initLabel(dic: [String:Any]) {
        
        label = InterestMarkModel(fromDic: dic)
    }
    mutating func initAuthor(dic: [String:Any]) {
        author = AuthorModel(fromDic: dic)
    }
    mutating func initChannel(dic: [String:Any]) {
        channel = ChannelModel(fromDic: dic)
    }
    mutating func initLabels(arr: [JSON]) {
        
        var xlabers :[InterestMarkModel] = []
        for object in arr {
            
            let xmodel = InterestMarkModel(fromDic: object.dictionary! )
            
            xlabers.append(xmodel)
        }
        labels = xlabers
    }
}
